<include file="Public:header" />
<div class="container main"> <include file="Public:left" />
  <div class="w790"> 
    <script>
  	//通过弹出窗口的形式打开添加字段信息页面
	function openupedit(url){
		art.dialog.open(url, {width: 600, height: 400,lock:true,title:'字段编辑', ok:			    	function(){
			var d = this.iframe.contentWindow.document;
			var img_list = new Array();
			$(d).find("input[name='mimg_url[]']").each(function(index, element) {
                img_list.push("'"+$(this).val()+"'");
            });
			var imgcate_id = $(d).find("#imgcate_id").val();
			$.post('{:U('insert')}',{img_list:img_list.toString(),imgcate_id:imgcate_id},function(data){
				if(data=='OK'){
						window.location.href = url;
					}
			});
			return false;
		}});
	}
  
  	function uploaded(path){
		$("#img_url").attr("src",'__PUBLIC__'+path);
		$("input[name='img_url']").val(path);
	}
	
	function del_img(){
		if(confirm('您确定要删除图片吗?')){
			var file=$("input[name='img_url']").val();
			$.post("{:U('delImgBypath')}",{'path':file},function(data){
				$("input[name='img_url']").val('');
				$("#img_url").attr('src','');
			});
		}else{
			return false;
		}
	}
	//删除图组图片
	function mdel_img(path){
		$('#img_list div img').each(function(index, element) {
			$.post("{:U('delImgBypath')}",{'path':path},function(data){
				
					
					$('#img_list div').each(function(index, element) {
                        if($(this).attr('url')==path){
							$(this).remove();
						}
                    });
					
					$('#picmsg input').each(function(index, element) {
                        if($(this).val()==path){
							$(this).remove();
						}
                    });
			
			});
		});
	}
	
	
	$(document).ready(function(e) {
    $('#control li').each(function(index, element) {
        $(this).click(function(e) {
			$(this).parent().find('li').removeClass('cur');
            $(this).addClass('cur');
			$('.setting_table').hide();
			$('.setting_table').eq(index).show();
        });
    });
});
function relateListadd(id,title,cate_name){
	//防止重复
	if(!$('#relateList input[value="'+id+'"]').length>0){
		$('<li>'+id+'<input type="hidden" name="relateid[]" value="'+id+'" /><input type="hidden" name="relatecate_name[]" value="'+cate_name+'" /><input size="70" type="text" name="relatetitle[]" value="'+title+'" /><a href="javascript:void(0);" onclick="after(this);">上</a><a href="javascript:void(0);" onclick="append(this);">下</a><span id="relateListdel'+id+'" class="relateListdel" onclick="relateListdel('+id+');">×</span></li>').appendTo('#relateList');
	}
}
function after(e){
	$(e).parent('li').after($(e).parent('li').prev());
}
function append(e){
	$(e).parent('li').next().after($(e).parent('li'));
}
function relateListdel(id){
	$('#relateListdel'+id).parent('li').remove();
}
function showRelate(){
			    art.dialog.open('{:U('News/relate')}', {width: 600, height: 400, ok:function(){
					
				}});
			}
  </script>
<div class="h"><a href="{:U('index')}" class="btn btn-info"><i class="glyphicon glyphicon-circle-arrow-left"></i> 返回表单列表</a>
 
 </div>
    
    <!--扩展切换-->

  
    <!---->
    <form class="checkoutform" action="{:U('update')}" method="post">
      <input type="hidden" name="is_list" value="1" />
      <div class="table_">
        <table class="table table-bordered" width="100%" border="0" cellspacing="0" class="setting_table" cellpadding="0">
        <tr>
          <td align="right">表单名称</td>
          <td><input datatype="*" style="display:none;" value="{$form.id}" name="id" type="text" id="title" size="70" >
            <input datatype="*" value="{$form.name}" name="name" type="text" id="title" size="70" ></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
        
        <tr>
          <td align="right">提交成功提示</td>
          <td><input datatype="*" value="{$form.successInfo}" name="successInfo" type="text" id="successInfo" size="70" ></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td align="right">提交周期（单位是秒）</td>
          <td><input datatype="*" value="{$form.cycle}" name="cycle" type="text" id="cycle" size="70" ></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td align="right">需要登录</td>
          <td><input type="radio" name="needLogin" value="1" 
            <eq name="form['needLogin']" value="1">checked</eq>
            >
            是 <input type="radio" name="needLogin" value="0" 
            <eq name="form['needLogin']" value="0">checked</eq>
            >
            否 </td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td align="right">启用验证码</td>
          <td><input type="radio" name="needVerify" value="1" 
            <eq name="form['needVerify']" value="1">checked</eq>
            >
            是 <input type="radio" name="needVerify" value="0" 
            <eq name="form['needVerify']" value="0">checked</eq>
            >
            否 </td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td align="right">成功跳转地址</td>
          <td><input datatype="*" value="{$form.successJumpUrl}" name="successJumpUrl" type="text" id="successJumpUrl" size="70" ></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2"><span>
            <volist name="list" id="vo">
              <input id="{$vo.id}" onclick="insertHtml('{<?php echo '$field_'.$vo['id'];?>}');" value="{$vo.id}-{$vo.name}" type="button"/>
            </volist>
            </span></td>
          <td><span><a href="javascript:;" onclick="openupedit('{:U('Field/add',array('formId'=>$form['id']))}');">添加新字段</a></span></td>
        </tr>
        <tr>
      
          <td colspan="3"><html:editor id="template" name="template" type="UEDIT" style="height:400px; width:100%;">{$form.template}</html:editor></td>
        </tr>
        <tr>
          <td colspan="3" align="left"><div id="img_list"></div></td>
        </tr>
        </table>
        <script>
	  //插入html内容到template编辑框
	  function insertHtml(html){
		  UE.getEditor('template').execCommand('insertHtml', html);
	  }
	  
	  </script> 
        
        <!--扩展开始--> 
      </div>
      <!--扩展结束-->
      <div class="pages">
        <button type="submit" class="mybutton">保存表单</button>
      </div>
    </form>
  </div>
  <div class="clear"></div>
</div>
</body></html>